package com.xihua.sx.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xihua.sx.pojo.Driver;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author astupidcoder
 * @since 2023-06-16
 */
@Mapper
@Repository
public interface DriverMapper extends BaseMapper<Driver> {

    /**分页多表查询，除了预定表中的数据之外，还需要车辆表的车牌号和车品牌，驾驶员表的驾驶员姓名和手机号码
     * @param page 分页对象 ，mybatis-plus 会自动的使用分页插件添加limit语句
     * @return
     */
    @Select("SELECT * " +
            "FROM `driver` ")
    Page<Driver> driverList(@Param("page")Page<Driver> page);

    /**
     * 动态sql查询，模糊查询
     * @param queryWrapper
     * @return
     */
//    @Select("SELECT r.*,ci.`car_code` as car_code,ci.`car_brand` as car_brand,d.`driver_name` as driver_name,d.`phone_number` as phone_number " +
//            "FROM `driver` r " +
//            "LEFT JOIN `driver` d ON d.`driver_id` = r.`driver_id` " +
//            "LEFT JOIN `car_info` ci ON ci.`car_id`=r.`car_id`  "+
//            "${ew.customSqlSegment} ")
//    List<Driver> driverLikeList(@Param("ew") QueryWrapper queryWrapper);

}
